<?
ob_start(); 
include("common/header.html");
include("../_made/le.cfg.php");
include("common/left.html");
include("common/page.php");
$out_html=ob_get_contents();
ob_end_clean();
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
if(!$_SESSION['memberID']){exit("<script>window.location='dlogin.html'</script>");}
$currentPage=$_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize=$_REQUEST['pageSize']?$_REQUEST["pageSize"]:10;
if($_REQUEST['act']=='loadExcel'){
$currentPage = 1;
$pageSize = 9999;
}
$txt=$_REQUEST['txt'];
$dtype=$_REQUEST['dtype'];
$ctype=$_REQUEST['com_type'];
$prov=$_REQUEST['d_province']?$_REQUEST['d_province']:0;
$city=$_REQUEST['d_city']?$_REQUEST['d_city']:0;
$mb=$tpl=$b=$a=$a_sort=array();
if(!$dtype){
$sel="select dtype from pft_member where id=".$_SESSION['sid']." limit 1";
$GLOBALS['le']->query($sel);
$GLOBALS['le']->fetch_assoc();
$dtype=$GLOBALS['le']->f("dtype");
}
if($_SESSION['group']){
$sel="select son_id from pft_member_relationship where status=0 and ship_type=1 and parent_id=".$_SESSION['group'];
$GLOBALS['le']->query($sel);
while($row=$GLOBALS['le']->fetch_assoc()){
$mb[]=$row['son_id'];
}
}
if($txt && $txt!="请输入企业名称\分销账号\手机"){
$tj=" and (instr(dname,'".$txt."') or instr(cname,'".$txt."') or account='".$txt."' or mobile='".$txt."')";
}
if($prov || $city || $ctype){
$a_t=" left join pft_member_extinfo e on e.fid=m.id ";
$a_tj.=$prov?" and province=".$prov:"";
$a_tj.=$city?" and city=".$city:"";
if($ctype){
$a_tj.=" and (";
foreach($ctype as $v){
$a_tj.="instr(com_type,'".$v."') or ";
}
$a_tj=trim($a_tj,"or ").")";
}
}
if($dtype==1){
$ltitle="供应商列表";
$sel1="select dname,cname,account,mobile,m.id,ship_type ";
$sel2="select count(*) total ";
$sel="from pft_member_relationship r left join pft_member m on m.id=parent_id ".$a_t." where m.status in (0,3) ".$tj.$a_tj." and r.status=0 and son_id=".$_SESSION['sid']." and ship_type=0";
}
elseif($dtype==7){
$_dtype=isset($_REQUEST['_dtype'])?$_REQUEST['_dtype']:"0,3";
$ltitle="集团成员列表";
$sel1="select dname,cname,account,mobile,m.id,ship_type,son_id_type ";
$sel2="select count(*) total ";
$sel="from pft_member_relationship r left join pft_member m on m.id=son_id ".$a_t." where m.status in (0,3) ".$tj.$a_tj." and r.status=0 and parent_id=".$_SESSION['sid']." and son_id_type in (".$_dtype.") and ship_type=1";
}
else{

$ltitle="分销商管理";
$sel="select id,title from uu_fx_pri_tpl where distid=".$_SESSION['sid'];
$GLOBALS['le']->query($sel);
while($row=$GLOBALS['le']->fetch_assoc()){
$tpl[]=$row;
}
$sel1="select dname,cname,account,mobile,m.id,son_id_type,ship_type ";
$sel2="select count(*) total ";
$sel="from pft_member_relationship r left join pft_member m on m.id=son_id ".$a_t." where m.status in (0,3) ".$tj.$a_tj." and r.status=0 and parent_id=".$_SESSION['sid']." and ship_type=0";
}
$GLOBALS['le']->query($sel1.$sel." limit ".($currentPage-1)*$pageSize.",".$pageSize);
while($row=$GLOBALS['le']->fetch_assoc()){
switch($row['son_id_type']){
case 0:$row['s_type']="分销商";break;
case 1:$row['s_type']="资源方";break;
}
if($dtype==1){$row['s_type']="供应商";}
switch($row['ship_type']){
case 0:$row['type']="供销关系";break;
case 1:$row['type']="从属关系";break;
case 2:$row['type']="平级关系";break;
case 3:$row['type']="推荐关系";break;
}
$a_sort[$row['id']]=$row;
}
$GLOBALS['le']->query($sel2.$sel);
$GLOBALS['le']->fetch_assoc();
$total=$GLOBALS['le']->f("total");
$parid=array_keys($a_sort);
if($dtype==0){
if($parid){
$sel="select fxid,tplid from uu_fx_tpl_cs where fxid in (".implode(",",$parid).")";
$GLOBALS['le']->query($sel);
while($row=$GLOBALS['le']->fetch_assoc()){
$_tpl[$row['fxid']]=$row['tplid'];
}
$_a=simplexml_load_string($s->PFT_Member_Fund(implode(",",$parid),1,$_SESSION['sid']));
foreach($_a as $v){
$a[(int)$v->UUfid]=$v->UUkmoney/100;
}
$_b=simplexml_load_string($s->PFT_Member_Fund(implode(",",$parid),2,$_SESSION['sid']));
foreach($_b as $v){
$b[(int)$v->UUfid]=$v->UUbasecredit/100;
}
}
}
elseif($dtype==7){
$parid=array();
$GLOBALS['le']->query("select son_id ".$sel);
while($row=$GLOBALS['le']->fetch_assoc()){
$parid[]=$row['son_id'];
}
if($parid){
$_a=simplexml_load_string($s->PFT_Member_Fund(implode(",",$parid),0));
foreach($_a as $v){
$count+=$a[(int)$v->UUfid]=$v->UUamoney/100;
}
}
}
else{
foreach($parid as $v){
$_a=simplexml_load_string($s->PFT_Member_Fund($_SESSION['sid'],1,$v));
$a[$v]=$_a->Rec[0]->UUkmoney/100;
$_b=simplexml_load_string($s->PFT_Member_Fund($_SESSION['sid'],2,$v));
$b[$v]=$_b->Rec[0]->UUbasecredit/100;
}
}
$txt=$txt?$txt:"请输入企业名称\分销账号\手机";
if($_GET['a']){
echo $dtype;
print_r($a_sort);
}
if($_REQUEST['act']=='loadExcel'){
$filename=date('YmdHis').'集团成员列表';
$Excel[0]['a']='企业名称（账号）';
$Excel[0]['b']='联系人';
$Excel[0]['c']='手机号码';
$Excel[0]['d']='资金金额';
$i=1;
foreach($a_sort as $data){
$n++;
$Excel[$n]['a']=$data['dname'].'('.$data['account'].')';
$Excel[$n]['b']=$data['cname'];
$Excel[$n]['c']=$data['mobile'];
$Excel[$n]['d']=(float)$a[$data['id']];
}
$xls = new SimpleExcel('UTF-8', true,'ml');
$xls->addArray($Excel);
$xls->generateXML($filename);
exit;
}
echo $out_html;
include("tpl/partner_zdt.html");
?>
<!--include("common/footer.html");-->